package com.ecode.annotation.model;

import com.sun.tools.javac.util.StringUtils;
import lombok.Data;

/**
 * @ClassName ErrorCodeDO
 * @Author mjlft
 * @Date 2021/9/25 12:34
 * @Version 1.0
 * @Description 错误码实体
 * 最终形成的错误为:
 * UP（sys+model+version+code）
 */
public class ErrorCodeDO {

    //系统标识
    private String sys;

    //模块标识
    private String model;

    //错误码版本
    private String version;

    //错误码
    private String code;

    //错误描述
    private String msg;

    public String buildCode() {
        StringBuffer errorCode =  new StringBuffer();
        errorCode.append(this.sys == null ? "" : this.sys.trim());
        errorCode.append(this.model == null ? "" : this.model.trim());
        errorCode.append(this.version == null ? "" : this.version.trim());
        errorCode.append(this.code == null ? "" : this.code.trim());
        return StringUtils.toUpperCase(errorCode.toString());
    }

    public String getSys() {
        return sys;
    }

    public void setSys(String sys) {
        this.sys = sys;
    }

    public String getModel() {
        return model;
    }

    public void setModel(String model) {
        this.model = model;
    }

    public String getVersion() {
        return version;
    }

    public void setVersion(String version) {
        this.version = version;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    @Override
    public String toString() {
        return "ErrorCodeDO{" +
                "sys='" + sys + '\'' +
                ", model='" + model + '\'' +
                ", version='" + version + '\'' +
                ", code='" + code + '\'' +
                ", msg='" + msg + '\'' +
                '}';
    }
}
